// 购买商店物品 {"编号":1,"序号":6,"数量":"1"}
// @ts-ignore
export async function execute(client_id, message_json) {
    let characters = G.Characters.get_current_login_characters(client_id);
    if (_CharactersOpoenStoreCache.has(characters["id"])) {
        let store_number = message_json["编号"];
        let num = message_json["数量"] || 1;
        let index = message_json["序号"];
        let shop_data = G.ShopStoreData.default[store_number];
        let store_type = G.ShopStoreData.ShopStoreEnum[shop_data[1]];
        if (shop_data === undefined) {
            ClientUtils.send_basic_prompt(client_id, "#R非法购买,商店不存在");
            return;
        }
        let list = shop_data[2];
        let item = list[index - 1];
        if (item === undefined || item === null) {
            ClientUtils.send_basic_prompt(client_id, "#R非法购买,物品不存在");
            return;
        }
        let sum = item[1] * num;
        if (characters[store_type] < sum) {
            ClientUtils.send_basic_prompt(client_id, `#Y${store_type}余额不足`);
            return;
        }
        characters[store_type] -= sum;
        G.Characters.add_item(characters["id"], item[0], num, `${shop_data[0]}购买`)
        ClientUtils.send_characters_shoping_list(characters["id"],store_number);
    } else {
        ClientUtils.send_basic_prompt(client_id, "#R非法购买,你并没有打开商店");
    }
}